package xxl.ioc.typedescriptions 
{
	import flash.utils.Dictionary;
	import xxl.ioc.Injector;
	/**
	 * ...
	 * @author XXL
	 */
	public class ConstructorInjectionPoint extends MethodInjectionPoint 
	{
		
		public function ConstructorInjectionPoint(parameters:Array, requiredParameters:uint, injectParameters:Dictionary) 
		{
			super("ctor"
				, parameters
				, requiredParameters
				, false
				, injectParameters);
		}
		
		public function createInstance(type:Class, injector:Injector):Object
		{
			const p:Array = gatherParameterValues(type, type, injector);
			var result:Object;
			switch(p.length)
			{
				case 1 : result = new type(p[0]); break;
				case 2 : result = new type(p[0], p[1]); break;
				case 3 : result = new type(p[0], p[1], p[2]); break;
				case 4 : result = new type(p[0], p[1], p[2], p[3]); break;
				case 5 : result = new type(p[0], p[1], p[2], p[3], p[4]); break;
				case 6 : result = new type(p[0], p[1], p[2], p[3], p[4], p[5]); break;
				case 7 : result = new type(p[0], p[1], p[2], p[3], p[4], p[5], p[6]); break;
				case 8 : result = new type(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); break;
				case 9 : result = new type(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8]); break;
				case 10 : result = new type(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]); break;
				default: throw new Error("目前只支持十个参数以内的构造函数"); break;
			}
			p.length = 0;
			return result;
		}
		
	}

}